package com.hhh.demo.sx.util;


/**
 * @author lenovo
 */
public class ResultMap<T> {

    private static final int CODE_SUCCESS = 200;

    private static final int CODE_FAIL = 400;

    private static final String MSG_SUCCESS="success";
    private static final String MSG_FAIL="failed";

    private int code;
    private T data;
    private String msg;

    public ResultMap(){

    }

    public ResultMap(int code){
        this.code = code;
    }

    public ResultMap(int code, T data){
        this.code = code;
        this.data = data;
    }

    public ResultMap(int code, String msg){
        this.code = code;
        this.msg = msg;
    }
    public ResultMap(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data=data;
    }
    public static ResultMap success(){
        return new ResultMap(CODE_SUCCESS,MSG_SUCCESS);
    }

    public static ResultMap success(Object data){
        return new ResultMap(CODE_SUCCESS,MSG_SUCCESS, data);
    }

    public static ResultMap fail(){
        return new ResultMap(CODE_FAIL, MSG_FAIL);
    }
    public static ResultMap fail(String msg){
        return new ResultMap(CODE_FAIL, msg);
    }


    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}